<h1 class="page-header">Servers</h1>

<div>
    <form style="margin-bottom: 3px;" class="form-inline">
        <button type="button" class="btn btn-success btn-sm" ng-click="create()">
            Create
        </button>

        <label for="proxies">Proxies</label>
        <select class="form-control" ng-model="proxyAddr" id="proxies">
            <option ng-repeat="p in proxies" value="{{p.conf.mgrAddr}}">{{p.conf.addr}}</option>
        </select>

        <label for="search">Search:</label>
        <input type="text" class="form-control" ng-model="q" id="search" />
    </form>
</div>

<div class="table-responsive">
    <table class="table table-bordered table-striped">
        <thead>
        <tr>
            <th >Addr</th>
            <th >Check Path</th>
            <th >Check Timeout</th>
            <th >Check Duration</th>
            <th >Max QPS</th>
            <th >Half to Open Secs</th>
            <th >Half Traffic Rate</th>
            <th >To Open Succeed Rate</th>
            <th >To Close Failure Rate</th>
            <th width="25%">opts</th>
        </tr>
        </thead>

        <tbody>
            <tr ng-repeat="server in servers | filter: q">
                <td><a href="#/servers/{{server.addr}}">{{server.addr}}</a></td>
                <td>{{server.checkPath}}</td>
                <td>{{server.checkTimeout}} sec</td>
                <td>{{server.checkDuration}} sec</td>
                <td>{{server.maxQPS}}</td>
                <td>{{server.halfToOpenSeconds}}</td>
                <td>{{server.halfTrafficRate}}</td>
                <td>{{server.halfToOpenSucceedRate}}% in {{server.halfToOpenCollectSeconds}} secs</td>
                <td>{{server.openToCloseFailureRate}}% in {{server.openToCloseCollectSeconds}} secs</td>
         <!--        <td>{{server.status | status}}</td> -->
                <td>
                        <button type="button" class="btn btn-success btn-sm" ng-click="goAnalysis(server.addr)">Analysis</button>
                        <button type="button" class="btn btn-success btn-sm" ng-click="delete(server.addr)">Delete</button>
                        <button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#myModal" ng-click="preBind(server.addr)">Bind</button>
                </td>
            </tr>
        </tbody>
    </table>
</div>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Servers</h4>
      </div>
      <div class="modal-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th></th>
                        <th>Name</th>
                        <th>Pattern</th>
                        <th>Load Balance</th>
                        <th>ServerCounts</th>
                    </tr>
                    </thead>

                    <tbody>
                        <tr ng-repeat="cluster in clusters | filter: q">
                            <td>
                                <input type="checkbox" ng-model="cluster.checked" />
                            </td>
                            <td>{{cluster.name}}</td>
                            <td>{{cluster.pattern}}</td>
                            <td>{{cluster.lbName}}</td>
                            <td>{{cluster.count}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="bind()">Bind</button>
      </div>
    </div>
  </div>
</div>